import request from '@/utils/request'

// 基础题库——基础题库列表
export function basisTesting(params) {
    return request({
        url: '/questions',
        params
    })
}

// 根据subjectID查找二级目录列表

export const getSubjects = (subjectID) => {
    return request({
        url: '/directorys/simple',
        method: 'GET',
        params: {
            subjectID
        }
    })
}

// 基础题库——基础题库添加
export function addBasisTesting(data) {
    return request({
        method: 'POST',
        url: '/questions',
        data
    })
}


// 基础题库——基础题库删除
export function deleteBasisTesting(id) {
    return request({
        method: 'DELETE',
        url: `/questions/${id}`
    })
}

// 基础题库——加入和移除精选
export function joinSelected(id, choiceState) {
    return request({
        method: 'PATCH',
        url: `/questions/choice/${id}/${choiceState}`
    })
}

// 获取科目列表

export const getSubjectsList = () => {
    return request({
        url: '/subjects/simple'
    })
}

// 获取标签目录列表

export const getlabelList = (subjectID) => {
    return request({
        url: 'tags/simple',
        params: {
            subjectID
        }
    })
}

// 将试题加入到精选题库

export const addToSelected = (id, choiceState) => {
    return request({
        url: `/questions/choice/${id}/${choiceState}`,
        method: 'PATCH'
    })
}

// 根据id删除试题

export const deleteQuestion = (id) => {
    return request({
        url: `/questions/${id}`,
        method: 'DELETE'
    })
}

// 根据id渲染题目详情
export const getQuestionDetail = (id) => {
    return request({
        url: `/questions/${id}`,
        params: {
            id
        }
    })
}

// 基础题库搜索
export const getSearchQuestions = (params) => {
    return request({
        url: '/questions',
        params
    })
}

// 获取企业目录
export const getCompanyList = (pagesize) => {
        return request({
            url: '/companys',
            params: {
                pagesize
            }
        })
    }
    // 新增基础试题
export const addBasicQuestion = (data) => {
    return request({
        url: 'questions',
        method: 'POST',
        data
    })
}

// 根据id获取试题详情
export const getBasicQuestionDetail = (id) => {
        return request({
            url: `/questions/${id}`
        })
    }
    // 根据id修改试题
export const updateBasicQuestion = (id, data) => {
    return request({
        url: `/questions/${id}`,
        method: 'PUT',
        data
    })
}